<?php
/**
 * 微信用户管理
 */
namespace backend\modules\admin\controllers;

use Yii;
use yii\data\ActiveDataProvider;
use backend\modules\admin\models\WeixinUser;
use yii\web\Response;
class WeixinUserController extends Controller
{

    public function init()
    {
        parent::init();
    }


    public function actionIndex()
    {
        $where = ['status'=>0];
        $dataProvider = new ActiveDataProvider([
            'query' => WeixinUser::find()->orderBy('id DESC'),
            'pagination' => [
                'pageSize' => 20,
            ],
        ]);

        return $this->render('index', [
            'dataProvider' => $dataProvider,
        ]);
    }

    public function actionLock($id)
    {
        Yii::$app->response->format=Response::FORMAT_JSON;
        $user = WeixinUser::findOne(['id' => $id]);
		if($user->status==1){
			$user->status = 0;
		}else{
			$user->status = 1;
		}
        $res = $user->save();
        if($res){
            return ['msg'=>'操作成功','status'=>1];
        }else{
            return ['msg'=>'操作失败','status'=>0];
        }
    }

}